//
//  Faxian_vc.m
//  ainkjj
//
//  Created by MAX on 2020/4/20.
//  Copyright © 2020 zhiyiLiu. All rights reserved.
//

#import "Faxian_vc.h"
#import "Tiezi_fabu_vc.h"
@interface Faxian_vc ()
@property (nonatomic, strong)NSMutableArray *titlesArr;
@property (nonatomic, strong)NSMutableArray *classNamesArr;
@property (nonatomic, strong)UIBarButtonItem *fabuItem;
@end

@implementation Faxian_vc
- (instancetype)init{
    self =  [super init];
    if (self) {
        self.showOnNavigationBar = YES;
        self.titleColorSelected = UIColor.whiteColor;
        self.titleColorNormal = UIColor.whiteColor;
        self.titleSizeNormal = 18;
        self.titleSizeSelected = 24;
        [self setMenuViewLayoutMode:WMMenuViewLayoutModeCenter];
        [self setItemsMargins:@[@(20), @(0), @(0)]];
        self.titleFontName = @"PingFangSC-Semibold";
        self.itemsWidths = @[@(120), @(120)];
        
//        self.fabuItem = [[UIBarButtonItem alloc] initWithImage:UIImageMake(@"issue_icon") style:UIBarButtonItemStylePlain target:self action:@selector(xxx_action)];
//        [self setMenuViewStyle:WMMenuViewStyleLine];
        
//        self.menuView.rightView = self.fabuItem;

    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:UIImageMake(@"issue_icon") style:UIBarButtonItemStylePlain target:self action:@selector(xxx_action)];

                                              

}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
   
}

- (void)xxx_action{
    Tiezi_fabu_vc *vc= [[Tiezi_fabu_vc alloc]init];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
- (NSMutableArray *)titlesArr{
    if(_titlesArr == nil)
    { _titlesArr = @[@"推荐", @"话题广场"].mutableCopy;
    }
    
    return _titlesArr;
}
- (NSMutableArray *)classNamesArr{
    if(_classNamesArr == nil)
    {_classNamesArr = @[ @"Tuijian_vc", @"Huati_guangchang_vc"].mutableCopy;
    }
    
    return _classNamesArr;
}

#pragma mark - WMPageController DataSource
- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController {
    return self.titlesArr.count;
}

- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index {
    return self.titlesArr[index];
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    UIViewController *vc = nil;
    vc = [NSClassFromString(self.classNamesArr[index]) new];
    
    return vc;
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView {

    CGFloat leftMargin =  0;
    CGFloat originY = self.showOnNavigationBar ? 0 : CGRectGetMaxY(self.navigationController.navigationBar.frame);
    return CGRectMake(leftMargin, originY, self.view.frame.size.width - 2*leftMargin, 44);
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView {

    CGFloat originY = CGRectGetMaxY([self pageController:pageController preferredFrameForMenuView:self.menuView]);
    originY = Lzy_StatusBarAndNavigationBarHeight;
    return CGRectMake(0, originY, self.view.frame.size.width, self.view.frame.size.height - originY - Lzy_TabbarHeight);
}

@end
